package com.ruoyi.web.controller.fx;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.fx.FxAppointmentItem;
import com.ruoyi.system.service.fx.IFxAppointmentItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 服务预约项
 *
 * @author ruoyi
 * @date 2025-04-29
 */
@RestController
@RequestMapping("/system/appointmentItem")
public class FxAppointmentItemController extends BaseController
{
    @Autowired
    private IFxAppointmentItemService fxAppointmentItemService;

    /**
     * 查询服务预约项列表
     * @return {@link FxAppointmentItem}
     */
    @GetMapping("/list")
    public TableDataInfo list(FxAppointmentItem fxAppointmentItem)
    {
        startPage();
        List<FxAppointmentItem> list = fxAppointmentItemService.selectFxAppointmentItemList(fxAppointmentItem);
        return getDataTable(list);
    }

    /**
     * 导出服务预约项列表
     */
    @Log(title = "服务预约项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FxAppointmentItem fxAppointmentItem)
    {
        List<FxAppointmentItem> list = fxAppointmentItemService.selectFxAppointmentItemList(fxAppointmentItem);
        ExcelUtil<FxAppointmentItem> util = new ExcelUtil<FxAppointmentItem>(FxAppointmentItem.class);
        util.exportExcel(response, list, "服务预约项数据");
    }

    /**
     * 获取服务预约项详细信息
     * @return {@link FxAppointmentItem}
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fxAppointmentItemService.selectFxAppointmentItemById(id));
    }

    /**
     * 新增服务预约项
     */
    @Log(title = "服务预约项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FxAppointmentItem fxAppointmentItem)
    {
        return toAjax(fxAppointmentItemService.insertFxAppointmentItem(fxAppointmentItem));
    }

    /**
     * 修改服务预约项
     */
    @Log(title = "服务预约项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FxAppointmentItem fxAppointmentItem)
    {
        return toAjax(fxAppointmentItemService.updateFxAppointmentItem(fxAppointmentItem));
    }

    /**
     * 删除服务预约项
     */
    @Log(title = "服务预约项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fxAppointmentItemService.deleteFxAppointmentItemByIds(ids));
    }
}
